interface IApi {
  request: any; // 业务指令的处理对象

  demand: any; // 资源指令的处理对象

  getApp(): any; // 全局缓存的处理对象

  checkData(data: any, type: string | CheckType): boolean; // 检查数据是否合法

  verifyData(data: any, type: string | CheckType): IVerifyData; // 验证数据是否合法

  formatData(data: any, type: string | FormatType, option?: string): any; // 格式化数据，时间单位为秒

  getUrlSuffixObj(url: string | undefined | string): object | null; // 获取Url后缀的对象

  getHtmlStyleObj(style: string | undefined | string): object | null; // 获取Html的Style的对象

  createInputObj(obj?: any): IInputObj; // 创建输入组件、选择组件、对话框组件的数据操作对象

  createAsynHandler(): IAsynHandler; // 异步设置和获取的操作对象

  log(tag: any, msg?: any): void; // 打印日志，对外版本会进行隐藏

  isDebugMode(): boolean; // 是否为开发版本，返回true则为开发版本

  getCurrentPlatform(): string | null; // 获取当前运行的平台，返回"web"、"alipay"、"wx"、"wechat"、"union"、"zkpark"、"zkroad"

  getAppConfig(): any; // 获取应用的配置

  toast(msg: any): void; // 显示提示框

  showLoading(msg?: string): void; // 显示加载框，需手动调用hideLoading进行隐藏

  hideLoading(): void; // 隐藏加载框

  showModal(param: IModal, callback?: typeof Callback): void; // 显示提示对话框

  getWindowWidth(): number; // 获取窗口的宽度，返回像素px

  getWindowHeight(): number; // 获取窗口的高度，返回像素px

  setPageTitle(title: string): void; // 设置当前页面的标题

  enablePullDownRefresh(component: object): void; // 允许下拉刷新

  disablePullDownRefresh(): void; // 禁止下拉刷新

  stopPullDownRefresh(): void; // 停止下拉刷新

  enableReachBottom(component: object): void; // 允许上拉加载

  disableReachBottom(): void; // 禁止上拉加载

  setClipboardData(text: string, callback?: typeof Callback): void; // 设置剪贴板的内容

  getClipboardData(callback: typeof StringCallback): void; // 获取剪贴板的内容

  jumpPlatformPage(dest?: string, param?: object | null, isFinish?: boolean): void; // 跳转到平台的页面

  jumpPlatformHomePage(dest: string, param?: object | null): void; // 跳转到平台的首页

  jumpMiniAppPage(appId: string, isRelease: boolean, dest: string, param?: object | null, isFinish?: boolean): void; // 跳转到小程序

  finishPage(backPageNum?: number): void; // 关闭页面，backPageNum不传则返回上一页

  jumpPage(dest: string, param?: object | null, isFinish?: boolean): void; // 跳转到下一个页面

  getPageParam(): object | null; // 获取上一个页面的传参

  getAccountCache(key: string): any; // 根据key获取本地数据

  setAccountCache(key: string, value?: any): void; // 设置本地数据，相同key则覆盖数据，value传undefined或null则移除对应的数据

  clearAccountCache(): void; // 清除本地数据

  getUrl(isShowLoading: boolean, url: string, param?: object | null, withoutAccount?: boolean, timeout?: number, linkId?: string): Promise<any>; // 发起get请求

  postUrl(isShowLoading: boolean, url: string, param?: object | null, withoutAccount?: boolean, timeout?: number, linkId?: string): Promise<any>; // 发起post请求

  deleteUrl(isShowLoading: boolean, url: string, param?: object | null, withoutAccount?: boolean, timeout?: number, linkId?: string): Promise<any>; // 发起delete请求

  putUrl(isShowLoading: boolean, url: string, param?: object | null, withoutAccount?: boolean, timeout?: number, linkId?: string): Promise<any>; // 发起put请求

  uploadFile(isShowLoading: boolean, url: string, fileName: string, filePath: string, formData: FormData): Promise<any>; // 发起上传文件请求

  loadScript(src: string, callback: typeof Callback): void; // 加载script模块

  getLocation(isShowLoading: boolean, param: ILocation, callback: typeof LocationCallback): void; // 获取当前位置

  previewImage(urls: Array<string>, startPosition?: number): void; // 查看全屏的图片

  chooseImage(sourceType: string | ChooseImageType, callback: typeof AnyCallback): void; // 选择图库  

  requestPayment(param: any, callback: typeof AnyCallback): void // 发起支付

  scanCode(scanType: string | ScanCodeType, callback: typeof AnyCallback): void // 扫码

  getAccount(callback: typeof AccountCallback): void; // 获取我的code和token

  getAccountCodeSync(): string; // 获取我的code，只返回本地数据

  getMyNameSync(): string; // 获取我的名字，只返回本地数据

  getMyIconSync(): string; // 获取我的头像，只返回本地数据

  getMyPhoneSync(): string; // 获取我的手机号，只返回本地数据
}

import {
  IModal, Callback, AnyCallback, ILocation, LocationCallback, ChooseImageType, ScanCodeType,
  AccountCallback, CheckType, IVerifyData, FormatType, StringCallback, IAsynHandler, IInputObj
} from "./apiType";
import engine from "./engine/engine";
function getEngine(): any { return engine; }
let api: IApi = getEngine();
export default api;